package com.linh.location;

import android.net.Uri;

public class BusUrl {

	static final String RETURN_LIST_PARAM = "ReturnList";
	static final String STOP_ID_PARAM = "StopID";
	static final String RETURN_LIST_VALUE = "StopPointName,StopID,Towards,Latitude,Longitude,LineID,DestinationName,EstimatedTime";
	static final String CIRCLE_PARAM = "Circle";
	static final String RADIUS = "500";// 500 m

	public static String getQueryUrl(String urlPrefix, double longitude,
			double latitude) {
		Uri.Builder builder = new Uri.Builder();

		String locationQuery = new StringBuilder().append(CIRCLE_PARAM)
				.append("=").append(latitude).append(",").append(longitude)
				.append(",").append(RADIUS).append("&")
				.append(RETURN_LIST_PARAM).append("=")
				.append(RETURN_LIST_VALUE).toString();
		return builder.scheme("http").appendEncodedPath(urlPrefix)
				.encodedQuery(locationQuery).build().toString();
	}

	public static String getSingleQuery(String urlPrefix, String stopId) {
		Uri.Builder builder = new Uri.Builder();

		String locationQuery = new StringBuilder().append(STOP_ID_PARAM)
				.append("=").append(stopId).append("&")
				.append(RETURN_LIST_PARAM).append("=")
				.append(RETURN_LIST_VALUE).toString();
		return builder.scheme("http").appendEncodedPath(urlPrefix)
				.encodedQuery(locationQuery).build().toString();
	}
}
